# -*- coding: utf-8 -*-
# @Time    : 2021/11/24 下午11:36
# @Author  : lilong
# @desc    :


import spacy
nlp = spacy.load("zh_core_web_sm")
ruler = nlp.add_pipe('entity_ruler')
patterns = [{"label": "A", "pattern": [{"POS": "NOUN", "OP":"?"},{"POS": "NOUN"}, {"ORTH": "电流"}]},\
            {"label": "T", "pattern": [{"POS": "NOUN", "OP":"?"},{"POS": "NOUN"}, {"ORTH": "温度"}]}]
ruler.add_patterns(patterns)
doc = nlp('启动一台真空泵，检查真空泵电机电流、入口压力、轴承温度、盘根温度、电机线圈温度、声音、振动正常。')
print([(ent.text, ent.label_) for ent in doc.ents])